package com.yixing.tech.common.utils;

import java.io.File;

public class FileUtil {
    public static void createParentDir(String path) {

        File file = new File(path);
        File parent = file.getParentFile();
        if (!parent.exists()) {
            parent.mkdirs();
        }

    }

    public static void deleteFile(String path) {

        File file = new File(path);
        if (file.exists()) {
            if (file.isFile()) {
                file.delete();
            } else {
                File[] files = file.listFiles();
                for (int i = 0; i < files.length; i++) {
                    deleteFile(files[i].getAbsolutePath());
                }
            }
        }

    }

    public static void createDir(String path) {

        File file = new File(path);
        if (!file.exists()) {
            file.mkdirs();
        }

    }
}
